<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>FAF-商家中心</title>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" type="text/css" href="css/mycss.css">
<link rel="stylesheet" type="text/css" href="css/mycss.css">
<link rel="stylesheet" type="text/css" href="css/file.css">
<link rel="stylesheet" type="text/css" href="css/button.css">
<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
	function checkOption() {
		console.log()
		if (document.getElementById("midfoodType").value == "炒菜") {
			document.getElementById("foodType").options[0].selected = true;
		} else if (document.getElementById("midfoodType").value == "凉菜") {
			document.getElementById("foodType").options[1].selected = true;
		} else if (document.getElementById("midfoodType").value == "速食") {
			document.getElementById("foodType").options[2].selected = true;
		} else if (document.getElementById("midfoodType").value == "主食") {
			document.getElementById("foodType").options[3].selected = true;
		} else if (document.getElementById("midfoodType").value == "饮品") {
			document.getElementById("foodType").options[4].selected = true;
		} else {
			document.getElementById("foodType").options[5].selected = true;
		}

	}
</script>
</head>
<body onload="checkOption();">
	<form action="../UpdateFoodManagement" method="post" id="updateFood"
		name="updateFood" enctype="multipart/form-data">
		<div class="header_con">
			<div class="header">
				<div class="welcome fl">欢迎来到好菜，好下饭!</div>
				<div class="fr">
					<div class="login_info fl">
						欢迎您：<em>张 山</em>
					</div>
					<div class="login_btn fl">
						<a href="/FAFCode/StoreLogout">注销</a>
					</div>
					<div class="user_link fl">
						<span>|</span> <a href="#">商家中心</a> <span>|</span> <a href="#">今日订单</a>
						<span>|</span> <a href="#">历史订单</a>
					</div>
				</div>
			</div>
		</div>

		<div class="search_bar clearfix">
			<a href="Index" class="logo fl"><img class="imgsize"
				src="/FAFCode/Image/logo/logo.jpg" width="80" height="80"></a>
			<div class="sub_page_name fl">|&nbsp;&nbsp;&nbsp;&nbsp;商家中心</div>
			<div class="search_con fr">
				<input type="text" class="input_text fl" name="" placeholder="搜索订单">
				<input type="button" class="input_btn fr" name="" value="搜索">
			</div>
		</div>

		<div class="main_con clearfix">
			<div class="left_menu_con clearfix">
				<h3>商家中心</h3>
				<ul>
					<li><a href="/FAFCode/PersonalInformation">· 个人信息</a></li>
					<li><a href="/FAFCode/OrderManagement/ViewOrders.jsp">·
							订单详情</a></li>
					<li><a href="/FAFCode/OrderManagement/Performance.html">·
							销售分析</a></li>
					<li><a href="/FAFCode/FoodManagement/addNewFood.jsp">·
							新增菜品</a></li>
					<li><a href="/FAFCode/FoodManagement/manageFood.jsp">·
							管理菜品</a></li>
					<li><a href="/FAFCode/FoodManagement/comment.jsp">· 查看评价</a></li>
				</ul>
			</div>

			<div class="right_content clearfix">
				<div class="info_con clearfix">
					<h3 class="common_title2">菜品信息</h3>
					<ul class="user_info_list">
						<li><span>菜名:</span><input type="text" id="foodName"
							name="foodName" value=<%=request.getParameter("foodName")%>></li>
						<li><span>价格:</span><input type="text" id="foodPrice"
							name="foodPrice" value=<%=request.getParameter("foodPrice")%>></li>
						<li><span>类型:</span><select id="foodType" name="foodType">
								<option value="炒菜">炒菜</option>
								<option value="凉菜">凉菜</option>
								<option value="速食">速食</option>
								<option value="主食">主食</option>
								<option value="饮品">饮品</option>
								<option value="水果">水果</option>
						</select></li>
						<li><span>详情描述:</span> <textarea rows="10" cols="20"
								id="foodDescribe" name="foodDescribe"><%=request.getParameter("foodDescribe")%></textarea></li>
						<li><input type="text" id="foodPhoto1" name="foodPhoto1"
							hidden="hidden" value="<%=request.getParameter("foodPhoto")%>"></li>
						<li><input type="text" id="midfoodType" name="midfoodType"
							hidden="hidden" value=<%=request.getParameter("foodType")%>></li>
						<li><input type="text" id="foodId" name="foodId"
							hidden="hidden" value=<%=request.getParameter("foodId")%>></li>
					</ul>
				</div>

				<h3 class="common_title2">上传图片</h3>
				<div class="has_view_list">
					<ul class="goods_type_list clearfix">
						<li><a href="javascript:;" class="a-upload"><input
								type="file" id="foodPhoto" name="foodPhoto"
								onchange="loadImageFile(event)">点击这里上传图片</a><img id="image"
							name="image" src="../<%=request.getParameter("foodPhoto")%>">
							<button id="save" name="save" class="button"
								onclick="submitbutton()">保存</button></li>
					</ul>
				</div>

			</div>
		</div>
		<div class="footer">
			<div class="foot_link">
				<a href="#">关于我们</a> <span>|</span> <a href="#">联系我们</a> <span>|</span>
				<a href="#">招聘人才</a> <span>|</span> <a href="#">友情链接</a>
			</div>
			<p>CopyRight © 2016 北京天天生鲜信息技术有限公司 All Rights Reserved</p>
			<p>电话：010-****888 京ICP备*******8号</p>
		</div>
	</form>
	<script>
		function loadImageFile(event) {
			var image = document.getElementById('image');
			image.src = URL.createObjectURL(event.target.files[0]);

		};
		function ffff() {
			$.ajax({
				type : 'post',
				dataType : "json",
				url : "../StoreFoodManagement",
				success : function(res) {
				},
				error : function() {
					alert("发生错误");
				}
			})
		}
		function submitbutton() {

			if (document.getElementById("foodName").value == "") {
				alert("请输入菜名!!!")
			} else if (document.getElementById("foodPrice").value == "") {
				alert("请输入价格!!!")
			} else if (!(document.getElementById("foodPrice").value
					.match(/^\+{0,1}\d+(\.\d{1,2})?$/) != null)) {
				alert("请输入正确的价格")
			} else if (document.getElementById("foodDescribe").value == "") {
				alert("请输入菜品描述!!!")
			} else {
				document.updateFood.action = "../UpdateFoodManagement";
				document.updateFood.submit();
			}
		}
	</script>
</html>